<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>短信接口设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<style>
    .layui-input-block {
        margin-left: 130px !important;
    }

    .layui-form-label {
        width: auto;
    }
</style>
<body style="height: 750px;background-color: white">

<div style="width:80%;height:100%;margin:15px auto;">
    <div style="margin-bottom: 100px;">Tips:国际短信服务购买(阿里云):<a href="https://market.aliyun.com/products/57126001/cmapi00040066.html" target="_blank"> https://market.aliyun.com/products/57126001/cmapi00040066.html</a>
        <div style="display: inline-block;">短信模板编辑:<a href="https://openali.esandcloud.com" target="_blank"> https://openali.esandcloud.com</a></div>
        <h3>非开发人员请勿修改</h3>
    </div>

    <div class="layui-form" action="">
        <div class="layui-form-item" id="title_div">
            <label class="layui-form-label">短信主机地址：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="host" required placeholder="短信主机地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" id="title_path">
            <label class="layui-form-label">短信接口地址：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="path" required placeholder="短信接口地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">AppCode：</label>
            <div class="layui-input-block">
                <input type="text" name="title_tai" id="AppCode" required lay-verify="required" placeholder="AppCode"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">短信模板id：</label>
            <div class="layui-input-block">
                <input type="text" name="title_tai" id="templetId" required lay-verify="required" placeholder="短信模板id"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="margin-top: 20px;margin: auto">
            <div class="layui-input-block">
                <button class="layui-btn" id="addWuye" lay-submit lay-filter="addWuye">立即修改</button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/js/layui/layui.js"></script>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>
<!-- 加载编辑器的容器 -->
<script id="container" name="content" type="text/plain">这里写你的初始化内容</script>
<!-- 配置文件 -->
<script type="text/javascript" src="/admin/ueditor/1.4.3/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/admin/ueditor/1.4.3/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
</html>
<script>
    var $ = layui.$;
    var upload = layui.upload;
    var layedit = layui.layedit;
    var form = layui.form;
    var laydate = layui.laydate;
    // 查询现有数据
    $.ajax({
        url:"/sms/getConfig",
        data:{id:'100'},
        type:"post",
        success:function (res) {
            $("#host").val(res.data.host)  ;
            $("#path").val(res.data.path)  ;
            $("#AppCode").val(res.data.appcode)  ;
            $("#templetId").val(res.data.templetId)  ;
        }
    })


    //添加操作
     $("#addWuye").click( function() {
         let host = $("#host").val();
         let path = $("#path").val();
         let appcode = $("#AppCode").val();
         let template = $("#templetId").val();
         if (host.length < 1) {
             layer.msg("主机名不能为空");
             $("#host").focus();
             return;
         }
         if (path.length < 1) {
             layer.msg("接口地址不能为空");
             $("#path").focus();
             return;
         }
         if (appcode.length < 1) {
             layer.msg("appcode不能为空");
             $("#appcode").focus();
             return;
         }
         if (template.length < 1) {
             $("#templetId").focus();
             layer.msg("短信模板不能为空");
             return;
         }
         // 提示是否确定修改
         layer.confirm("确定修改配置?", ["确定", "取消"], function () {
             $.ajax({
                 url: '/sms/updateConfig',
                 data: {'id': "100", "host": host, "path": path, "appcode": appcode, "templetId": template},
                 success: function (data) {
                     if (data.code == 200) {
                         layer.msg("修改成功",{time:1000},function () {
                             location.reload();
                         });
                     }
                 }
             })
         });
     })


</script>
</html>